<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.js"></script>
    <title>p65ref获取dom元素和组件,父组件去子组件的数据，父组件调用子组件的方法</title>
</head>
<body>
    <div id="app">
        <h3 ref="myh3">这是一条message</h3>
        <input type="button" value="获取元素" @click="getEle">
        <login ref="mylogin"></login>
    </div>
    <script>

    var login={
        template:"<h1>这是登录组件</h1>",
        data(){
            return{
                msg:"这是子组件的数据"
            }
        },
        methods:{
            show(){
                console.log("这是子组件的方法");
            }
        }
    }    
    var vm=new Vue({
        el:"#app",
        data:{},
        methods:{
            getEle:function(){
                // console.log(this.$refs.myh3.innerText)
                console.log(this.$refs.mylogin.msg);
                this.$refs.mylogin.show();
            }
        },
        filters:{},
        directives:{},
        components:{
            login
        }
    })
    </script>
</body>
</html>